package com.dede.getmusic.data

import java.io.Serializable

/**
 * @author hsh
 * @date 2017/10/10 10:00.
 * @doc 歌曲文件信息
 */
class SongFileInfo : Serializable {

    var name: String = ""//歌曲名
    var fileName: String = ""//文件名
    var artist: String = ""//歌手
    var album: String = ""//专辑
    var url: String = ""
    var id: Int = -1//音乐id

    companion object {
        fun createSongFileInfo(songsBean: SearchInfo.SongsBean, linkInfo: SongLinkInfo): SongFileInfo {
            val info = SongFileInfo()
            info.id = songsBean.id
            info.name = songsBean.name
            info.album = songsBean.album?.name ?: ""
            var artistStr = ""
            for (artist in songsBean.artists) {
                artistStr += artist.name + "、"//这里使用顿号分割歌手名，不使用'/'，文件系统命名冲突
            }
            if (songsBean.artists.isNotEmpty()) {
                artistStr = artistStr.substring(0, artistStr.length - 1)
            }
            info.artist = artistStr
            info.fileName = artistStr + " - " + info.name + "." + linkInfo.type
            info.url = linkInfo.url
            return info
        }
    }

}
